package com.bjqh.edu.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bjqh.edu.Base.AppConstants;
import com.bjqh.edu.Bean.HistoricalGrade;
import com.bjqh.edu.R;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/10/9.
 */

public class HistoricalGradeAdapter extends BaseAdapter {
    private List<HistoricalGrade.RowsBean> list;
    private Context ctx;
    private ViewHolder holder;

    public HistoricalGradeAdapter(Context ctx, List<HistoricalGrade.RowsBean> list) {
        this.ctx = ctx;
        this.list = list;

    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }


    @Override
    public View getView(final int i, View view, ViewGroup viewGroup) {
        if (view == null) {
            view = LayoutInflater.from(ctx).inflate(R.layout.item_historical_grade, null);
            holder = new ViewHolder(view);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        holder.tvGrade.setText(list.get(i).getGradeName());
        holder.tvCourse.setText(list.get(i).getCourseName());
        holder.tvAchievement.setText(list.get(i).getScore());
        holder.tvTime.setText(AppConstants.gettimes(list.get(i).getTime()));

        return view;
    }

    static


    class ViewHolder {
        @BindView(R.id.tv_grade)
        TextView tvGrade;
        @BindView(R.id.tv_course)
        TextView tvCourse;
        @BindView(R.id.tv_achievement)
        TextView tvAchievement;
        @BindView(R.id.tv_time)
        TextView tvTime;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
